package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.annotation.log.WebLog;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.service.BHl7YzYaoExeService;
import top.tangyh.lamp.care.entity.BHl7YzYaoExe;
import top.tangyh.lamp.care.vo.query.ExeYaoQueryVO;
import top.tangyh.lamp.care.vo.result.ExeYaoOutVO;
import top.tangyh.lamp.care.vo.result.OperaInfoOutVO;
import top.tangyh.lamp.care.vo.result.RkYongYaoOutVO;
import top.tangyh.lamp.care.vo.save.BHl7YzYaoExeSaveVO;
import top.tangyh.lamp.care.vo.save.RkYongYaoInVO;
import top.tangyh.lamp.care.vo.update.BHl7YzYaoExeUpdateVO;
import top.tangyh.lamp.care.vo.result.BHl7YzYaoExeResultVO;
import top.tangyh.lamp.care.vo.query.BHl7YzYaoExePageQuery;

import java.util.List;

import static top.tangyh.basic.base.R.success;
import static top.tangyh.lamp.common.constant.SwaggerConstants.DATA_TYPE_LONG;
import static top.tangyh.lamp.common.constant.SwaggerConstants.DATA_TYPE_STRING;

/**
 * <p>
 * 前端控制器
 * 医嘱实际执行表
 * </p>
 *
 * @author zqb
 * @date 2024-07-22 15:09:14
 * @create [2024-07-22 15:09:14] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/yongyao")
@Tag(name = "HL7:入科前用药")
public class BHl7YzYaoExeController  {
//    extends SuperController<BHl7YzYaoExeService, Integer, BHl7YzYaoExe
//            , BHl7YzYaoExeSaveVO, BHl7YzYaoExeUpdateVO, BHl7YzYaoExePageQuery, BHl7YzYaoExeResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }

    private  final BHl7YzYaoExeService bHl7YzYaoExeService;


    @Parameters({
            @Parameter(name = "hospitalNumber", description = "住院号", schema = @Schema(type = DATA_TYPE_STRING), in = ParameterIn.QUERY),
            @Parameter(name = "rkTimeLong", description = "入科时间", schema = @Schema(type = DATA_TYPE_LONG), in = ParameterIn.QUERY),
    })
    @Operation(summary = "查询入科前用药列表")
    @GetMapping("/list")
    @WebLog(value = "查询入科前用药列表")
    public R<List<RkYongYaoOutVO>> listOperaInfo(@RequestParam String hospitalNumber,@RequestParam Long rkTimeLong) {
        return success(bHl7YzYaoExeService.listRkYongYaoOutVO(hospitalNumber,rkTimeLong));
    }


    @Operation(summary ="添加用药")
    @PostMapping("/add")
    public R add(@RequestBody RkYongYaoInVO infoInVO) {
        bHl7YzYaoExeService.addRkYongYaoInfo(infoInVO);
        return R.success();
    }

    @Operation(summary ="修改用药")
    @PutMapping("/update")
    public R update(@RequestBody RkYongYaoInVO infoInVO) {
        bHl7YzYaoExeService.updateRkYongYaoInfo(infoInVO);
        return R.success();
    }

    @Operation(summary ="删除用药")
    @DeleteMapping("/delete")
    public R delete(Long id) {
        bHl7YzYaoExeService.deleteRkYongYaoInfo(id);
        return R.success();
    }


    @Operation(summary ="查询执行用药列表(护理记录里用到)")
    @PostMapping("/exe/yao/list")
    public R<List<ExeYaoOutVO>> selectListByQuery(@RequestBody ExeYaoQueryVO queryVO) {
        List<ExeYaoOutVO> result = bHl7YzYaoExeService.selectExeYaoListNoEventByQuery(queryVO);
        return R.success(result);
    }
}


